//
//  HMViewController.m
//  HMCycleImageView
//
//  Created by wy46817@gmail.com on 09/10/2017.
//  Copyright (c) 2017 wy46817@gmail.com. All rights reserved.
//

#import "HMViewController.h"
#import <HMCycleImageView/HMCycleImageView.h>
#import <Masonry/Masonry.h>

@interface HMViewController () <HMCycleImageViewDelegate,HMCycleImageViewDataSourse>

@property(nonatomic,strong) HMCycleImageView *cycleImageView;

@end

@implementation HMViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.automaticallyAdjustsScrollViewInsets = NO;

    self.cycleImageView = [HMCycleImageView new];

    [self.view addSubview:self.cycleImageView];

    [self.cycleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(375, 600));
    }];

    self.cycleImageView.delegate = self;
    self.cycleImageView.datasource = self;
    [self.cycleImageView reloadData];

}

#pragma mark - HMCycleImageViewDataSourse -
- (NSInteger)numberOfItemsInCycleImageView:(HMCycleImageView *)cycleImageView{
    return  5;
}

- (NSURL *)cycleImageView:(HMCycleImageView *)cycleImageView itemUrlAtIndex:(NSInteger)index{
    switch (index) {
        case 0:
            return [NSURL URLWithString:@"https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=c0f041335c6034a829b7b085fe236562/2934349b033b5bb5903fe8cc36d3d539b600bc1c.jpg"];
            break;
        case 1:
            return [NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1505061524029&di=eaf8d1f62f2108640cb9eea76030c50e&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Fc8ea15ce36d3d539ebd5c7f13a87e950352ab01c.jpg"];
            break;
        case 2:
            return [NSURL URLWithString:@"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2201498555,2073161310&fm=27&gp=0.jpg"];
            break;
        case 3:
            return [NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1505061629293&di=6eb02fb6acf4dafd340beba493a30aa4&imgtype=0&src=http%3A%2F%2Fww1.sinaimg.cn%2Fmw690%2Fcb8cfb14gw1f1qw8l5wa0j20dw0kajsc.jpg"];
            break;
        case 4:
            return [NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1505061658578&di=72dfa1256fa1b3732da0c6abb948da3b&imgtype=0&src=http%3A%2F%2Fstatic.vgtime.com%2Fphoto%2Fweb%2F151118181431702.png"];
            break;

        default:
            break;
    }
    return nil;
}

#pragma mark - HMCycleImageViewDelegate -

@end
